<template>
  <div>
    <el-tag class="check">裱纸</el-tag>
      <el-checkbox @change="clickToChange('biao_ka')">裱卡</el-checkbox>
      <el-checkbox @change="clickToChange('biao_keng')">裱坑</el-checkbox>
      <div class="content" v-if="!biaozhi.biao_ka.disable">
      <h5>裱卡</h5>
      <span>层数:</span>
      <el-input v-model="biaozhi.biao_ka.ceng_shu" placeholder="请输入层数" :disabled="biaozhi.biao_ka.disable"
                size="small" class = "length" @input="jud_ka"></el-input>
      <div class="content" v-for="i in range(biaozhi.biao_ka.ceng_shu)" :key="i">
        <span class="color">第{{i+1}}层:</span>
        <br/>
        <span>纸类:</span>
        <el-select v-model="biaozhi.biao_ka['child'+i].zhi_lei" :disabled="biaozhi.biao_ka.disable"
                   placeholder="请选择" size="small" class="length" @change="clearInfo('biao_ka', i)">
          <el-option v-for="item in option.zhong_lei" :key="item" :label="item" :value="item"></el-option>
        </el-select>
        <span>克重:</span>
        <el-select v-model="biaozhi.biao_ka['child'+i].ke_zhong" :disabled="biaozhi.biao_ka.disable"
                   placeholder="请选择" size="small" class="length" @change="getPrice('biao_ka', i)">
          <el-option v-for="item in option.ke_zhong[lei_name('biao_ka', i)]" :key="item" :label="item" :value="item"></el-option>
        </el-select>
        <input v-model.lazy="biaozhi.biao_ka['child'+i].ke_zhong" placeholder="请输入单价"
               v-if="biaozhi.biao_ka['child'+i].ke_zhong ==='自填'" class="length" @blur="change"/>
        <br/>
        <span>材料单价(单位：元/吨):</span>
        <el-select v-model="biaozhi.biao_ka['child'+i].dan_jia" :disabled="biaozhi.biao_ka.disable"
                   placeholder="请选择" class="length" size="small" @change="change()">
          <el-option v-for="item in option.dan_jia[lei_name('biao_ka', i)]" :key="item" :label="item" :value="item"></el-option>
        </el-select>
        <input v-model.lazy="biaozhi.biao_ka['child'+i].dan_jia" placeholder="请输入单价"
               v-if="biaozhi.biao_ka['child'+i].dan_jia ==='自填'" class="length" @blur="change"/>
        <br/>
        <div class="lengthq">成本: {{computeCost(i)}}</div>
        <br/>
        <div>
        <el-checkbox @change="print_disable = !print_disable"></el-checkbox>
        <span class="print_color">印刷:</span>
        <el-select v-model="biaozhi.biao_ka['child'+i].yin_shuang" :disabled="biaozhi.biao_ka.disable || print_disable"
                   placeholder="请选择" size="small" class="length" @change="change()">
          <el-option v-for="item in option.ying_shua" :key="item" :label="item" :value="item"></el-option>
        </el-select>
        <span v-if="biaozhi.biao_ka['child'+i].yin_shuang.indexOf('C') !== -1">四色：</span>
        <el-select v-model="biaozhi.biao_ka['child'+i].se_type" v-if="biaozhi.biao_ka['child'+i].yin_shuang.indexOf('C') !== -1"
                   placeholder="请选择" size="small" class="length" @change="change()">
          <el-option v-for="item in option.printf_option_bu" :key="item" :label="item" :value="item"></el-option>
        </el-select>
        <span v-if="biaozhi.biao_ka['child'+i].yin_shuang.indexOf('专') !== -1">专色:</span>
        <el-select v-model="biaozhi.biao_ka['child'+i].se_type" v-if="biaozhi.biao_ka['child'+i].yin_shuang.indexOf('专') !== -1"
                   placeholder="请选择" size="small" class="length" @change="change()">
          <el-option v-for="item in option.printf_option_bu" :key="item" :label="item" :value="item"></el-option>
        </el-select>
        <div class="lengthq">四色成本: {{computePrintCost(i)[0]}}</div>
        <div class="lengthq">专色成本: {{computePrintCost(i)[1]}}</div>
        </div>
        <br/>
        <el-checkbox @change="hou_disable = !hou_disable"></el-checkbox>
        <span class="hou_color">后工:</span>
        <el-select v-model="biaozhi.biao_ka['child'+i].hou_gong" :disabled="biaozhi.biao_ka.disable || hou_disable"
                   placeholder="请选择" size="small" class="length" @change="change()">
          <el-option v-for="item in option.hou_gong" :key="item" :label="item" :value="item"></el-option>
        </el-select>
        <div v-if="biaozhi.biao_ka['child'+i].hou_gong === '覆膜'" class="content_inline">
          <div>
            <span>正面：</span>
            <el-select v-model="biaozhi.biao_ka['child'+i].fu_mo_zheng_mian"
                       placeholder="请选择" class="length" size="small" @change="change">
              <el-option v-for="item in option.fu_mo_option" :key="item" :label="item" :value="item"></el-option>
            </el-select>
            <span>反面：</span>
            <el-select v-model="biaozhi.biao_ka['child'+i].fu_mo_fan_mian"
                       placeholder="请选择" class="length" size="small" @change="change">
              <el-option v-for="item in option.fu_mo_option" :key="item" :label="item" :value="item"></el-option>
            </el-select>
          </div>
          </div>
        <div v-if="biaozhi.biao_ka['child'+i].hou_gong === '过油'" class="content_inline">
          <div>
            <span>正面：</span>
            <el-select v-model="biaozhi.biao_ka['child'+i].guoyou_zheng_mian"
                       placeholder="请选择" class="length" size="small" @change="change">
              <el-option v-for="item in option.guo_you_option" :key="item" :label="item" :value="item"></el-option>
            </el-select>
            <span>反面：</span>
            <el-select v-model="biaozhi.biao_ka['child'+i].guoyou_fan_mian"
                       placeholder="请选择" class="length" size="small" @change="change">
              <el-option v-for="item in option.guo_you_option" :key="item" :label="item" :value="item"></el-option>
            </el-select>
          </div>
        </div>
        <div v-if="biaozhi.biao_ka['child'+i].hou_gong === '烫金'" class="content_inline">
          <div>
            <span>面积(单位:cm)：</span>
            <el-input v-model="biaozhi.biao_ka['child'+i].tang_jin_chang"
                      placeholder="请输入长" size="small" class = "length" @input="change"></el-input>
            <el-input v-model="biaozhi.biao_ka['child'+i].tang_jin_kuan"
                      placeholder="请输入宽" size="small" class = "length" @input="change"></el-input>
            <span>金纸：</span>
            <el-input v-model="biaozhi.biao_ka['child'+i].tang_jin_jin_zhi"
                      placeholder="请输入总价" size="small" class = "length" @input="change"></el-input>
            <span>次数:</span>
            <el-input v-model="biaozhi.biao_ka['child'+i].ci_shu"
                      placeholder="模数" size="small" class = "length" @input="change"></el-input>
          </div>
        </div>
        <div class="lengthq" v-if="biaozhi.biao_ka['child'+i].hou_gong === '覆膜'">正面:{{computeFumoCost(i)[0]}}</div>
        <div class="lengthq" v-if="biaozhi.biao_ka['child'+i].hou_gong === '覆膜'">反面:{{computeFumoCost(i)[1]}}</div>
        <div class="lengthq" v-if="biaozhi.biao_ka['child'+i].hou_gong === '过油'">正面:{{computeGuoyouCost(i)[0]}}</div>
        <div class="lengthq" v-if="biaozhi.biao_ka['child'+i].hou_gong === '过油'">反面:{{computeGuoyouCost(i)[1]}}</div>
        <div class="lengthq" v-if="biaozhi.biao_ka['child'+i].hou_gong === '烫金'">成本:{{computeTangjinCost(i)}}</div>
      </div>
    </div>
      <div class="content" v-if="!biaozhi.biao_keng.disable">
      <h5>裱坑</h5>
        <span>层数:</span>
        <el-input v-model="biaozhi.biao_keng.ceng_shu" placeholder="请输入层数" :disabled="biaozhi.biao_keng.disable"
                size="small" class = "length" @input="jud_keng"></el-input>
        <div class="content" v-for="i in range1(biaozhi.biao_keng.ceng_shu)" :key="i">
          <span class="color">第{{i + 1}}层:</span>
          <br/>
          <span>纸类:</span>
          <el-select v-model="biaozhi.biao_keng['child'+i].zhi_lei"
                     placeholder="请选择" size="small" class="length" @change="clearInfo('biao_keng', i)">
            <el-option v-for="item in option.zhong_lei" :key="item" :label="item" :value="item"></el-option>
          </el-select>
          <span>克重:</span>
          <el-select v-model="biaozhi.biao_keng['child'+i].ke_zhong"
                     placeholder="请选择" size="small" class="length" @change="getPrice('biao_keng', i)">
            <el-option v-for="item in option.ke_zhong[lei_name('biao_keng', i)]" :key="item" :label="item" :value="item"></el-option>
          </el-select>
          <input v-model.lazy="biaozhi.biao_keng['child'+i].ke_zhong" placeholder="请输入单价"
                 v-if="biaozhi.biao_keng['child'+i].ke_zhong ==='自填'" class="length" @blur="change"/>
          <span>材料单价(单位：元/吨):</span>
          <el-select v-model="biaozhi.biao_keng['child'+i].dan_jia"
                     placeholder="请选择" class="length" size="small" @change="change()">
            <el-option v-for="item in option.dan_jia[lei_name('biao_keng', i)]" :key="item" :label="item" :value="item"></el-option>
          </el-select>
          <input v-model.lazy="biaozhi.biao_keng['child'+i].dan_jia" placeholder="请输入单价"
                 v-if="biaozhi.biao_keng['child'+i].dan_jia ==='自填'" class="length" @blur="change"/>
          <br/>
          <div class="lengthq">成本: {{computeCost_(i)}}</div>
        </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'Biaozhi',
  props: ['Q', 'x', 'y', 'm', 'confirm'],
  data () {
    return {
      print_disable: true,
      hou_disable: true,
      biaozhi: {
        biao_ka: {disable: true, ceng_shu: 0},
        biao_keng: {disable: true, ceng_shu: 0}
      },
      option: {
        ke_zhong: {
          baiban: [230, 250, 300, 350, 400, '自填'],
          baika: [250, 300, 350, 400, '自填'],
          shuangtong: [105, 128, 157, 200, 250, 300, 350, 400, '自填']
        },
        dan_jia: {
          baiban: [5000, 4900, 4800, 4700, 4600, '自填'],
          baika: [5300, 5200, 5100, 5000, '自填'],
          shuangtong: [6000, 5900, 5800, '自填']
        },
        zhong_lei: ['双铜', '白卡', '白板', '双白', '银卡', '金卡'],
        printf_option_bu: ['六开', '四开', '对开', '全开'],
        ying_shua: ['4C', '4C+1专', '4C+2专', '4C+3专', '4C+4专', '1专', '2专', '3专', '4专', '无印刷'],
        hou_gong: ['覆膜', '过油', '烫金'],
        fu_mo_option: ['光膜', '哑膜', '干光膜', '干哑膜', '触感膜', '雪花膜', '防刮膜'],
        guo_you_option: ['光油', '哑油', '高光油', '吸塑油', '二次吸塑油', '环保油', '二次环保油', '扑克油']
      }
    }
  },
  methods: {
    range (num) {
      let x = []
      for (let i = 0; i < num; i++) {
        x.push(i)
        if (this.biaozhi.biao_ka['child' + i] === undefined) {
          this.biaozhi.biao_ka['child' + i] = {
            zhi_lei: '',
            se_type: '',
            ke_zhong: '',
            dan_jia: '',
            yin_shuang: '',
            hou_gong: '',
            fu_mo_zheng_mian: '',
            fu_mo_fan_mian: '',
            guoyou_zheng_mian: '',
            guoyou_fan_mian: '',
            tang_jin_chang: '',
            tang_jin_kuan: '',
            tang_jin_jin_zhi: 0,
            ci_shu: 0
          }
        }
      }
      return x
    },
    range1 (num) {
      let x = []
      for (let i = 0; i < num; i++) {
        x.push(i)
        if (this.biaozhi.biao_keng['child' + i] === undefined) {
          this.biaozhi.biao_keng['child' + i] = {
            zhi_lei: '',
            dan_jia: '',
            ke_zhong: ''
          }
        }
      }
      return x
    },
    change () {
      this.$forceUpdate()
    },
    jud_ka () {
      if (this.biaozhi.biao_ka.ceng_shu > 9) {
        this.$message.error('请勿输入大于9层')
        this.biaozhi.biao_ka.ceng_shu = 9
      }
    },
    jud_keng () {
      if (this.biaozhi.biao_keng.ceng_shu > 9) {
        this.$message.error('请勿输入大于9层')
        this.biaozhi.biao_keng.ceng_shu = 9
      }
    },
    computeCost (k) {
      let x = parseInt(this.x)
      let y = parseInt(this.y)
      let q = parseInt(this.Q)
      let price = parseInt(this.biaozhi.biao_ka['child' + k].dan_jia)
      let ke = parseInt(this.biaozhi.biao_ka['child' + k].ke_zhong)
      let cost = 0
      let costStr = ''
      if (x < y) {
        cost = (x + 15) * (y + 10) * q * price * ke / Math.pow(10, 12)
        if (cost <= 1300) {
          costStr = `(${x}+15) × (${y}+10) × ${q} × ${price} × ${ke} × (10^-12) + 30 = ${cost + 30}`
        } else costStr = `(${x}+15) × (${y}+10) × ${q} × ${price} × ${ke} × (10^-12) = ${cost}`
      } else {
        cost = (x + 10) * (y + 15) * q * price * ke / Math.pow(10, 12)
        if (cost <= 1300) {
          costStr = `(${x}+10) × (${y}+15) × ${q} × ${price} × ${ke} × (10^-12) + 30 = ${cost + 30}`
        } else costStr = `(${x}+10) × (${y}+15) × ${q} × ${price} × ${ke} × (10^-12) = ${cost}`
      }
      return costStr
    },
    computeCost_ (k) {
      let x = parseInt(this.x)
      let y = parseInt(this.y)
      let q = parseInt(this.Q)
      let price = parseInt(this.biaozhi.biao_keng['child' + k].dan_jia)
      let ke = parseInt(this.biaozhi.biao_keng['child' + k].ke_zhong)
      let cost = 0
      let costStr = ''
      if (x < y) {
        cost = (x + 15) * (y + 10) * q * price * ke / Math.pow(10, 12)
        if (cost <= 1300) {
          costStr = `(${x}+15) × (${y}+10) × ${q} × ${price} × ${ke} × (10^-12) + 30 = ${cost + 30}`
        } else costStr = `(${x}+15) × (${y}+10) × ${q} × ${price} × ${ke} × (10^-12) = ${cost}`
      } else {
        cost = (x + 10) * (y + 15) * q * price * ke / Math.pow(10, 12)
        if (cost <= 1300) {
          costStr = `(${x}+10) × (${y}+15) × ${q} × ${price} × ${ke} × (10^-12) + 30 = ${cost + 30}`
        } else costStr = `(${x}+10) × (${y}+15) × ${q} × ${price} × ${ke} × (10^-12) = ${cost}`
      }
      return costStr
    },
    computePrintCost (k) {
      let type = this.biaozhi.biao_ka['child' + k].yin_shuang
      if (type === '无印刷') {
        return [0, 0]
      }
      let Q = parseInt(this.Q)
      let siSeCost = 0
      let siSeCostStr = '0'
      let zhuanSeCost = 0
      let zhuanSeCostStr = '0'
      if (type.indexOf('C') !== -1) {
        // let num = parseInt(type[3])
        switch (this.biaozhi.biao_ka['child' + k].se_type) {
          case '六开':
            siSeCost = Q <= 1000 ? 160 : 160 + 30 * ((Q - 1000) / 1000)
            siSeCostStr = Q <= 1000 ? '160' : `160 + 30 × ((${Q} - 1000) / 1000) = ${siSeCost}`
            break
          case '四开':
            siSeCost = Q <= 1000 ? 260 : 260 + 40 * ((Q - 1000) / 1000)
            siSeCostStr = Q <= 1000 ? '260' : `260 + 40 × ((${Q} - 1000) / 1000) = ${siSeCost}`
            break
          case '对开':
            siSeCost = Q <= 1000 ? 400 : 400 + 50 * ((Q - 1000) / 1000)
            siSeCostStr = Q <= 1000 ? '400' : `400 + 50 × ((${Q} - 1000) / 1000) = ${siSeCost}`
            break
          case '全开':
            siSeCost = Q <= 5000 ? 1100 + 100 * ((Q - 1000) / 1000) : 0.3 * (Q - 1000)
            siSeCostStr = Q <= 5000 ? `1100 + 100 × ((${Q} - 1000) / 1000) = ${siSeCost}` : `0.3 × (${Q} - 1000) = ${siSeCost}`
            break
          default:
            siSeCost = 0
            siSeCostStr = '0'
        }
      }
      if (type.indexOf('专') !== -1) {
        let n = parseInt(type[type.indexOf('专') - 1])
        switch (this.biaozhi.biao_ka['child' + k].se_type) {
          case '六开':
            zhuanSeCost = Q <= 1000 ? 120 * n : 120 * n + 30 * ((Q - 1000) / 1000)
            zhuanSeCostStr = Q <= 1000 ? `120 × ${n} = ${zhuanSeCost}`
              : `120 × ${n} + 30 × ((${Q} - 1000) / 1000) = ${zhuanSeCost}`
            break
          case '四开':
            zhuanSeCost = Q <= 1000 ? 260 + 100 * (n - 1) : 260 + 100 * (n - 1) + 50 * ((Q - 1000) / 1000)
            zhuanSeCostStr = Q <= 1000 ? `260 + 100 × (${n} - 1) = ${zhuanSeCost}`
              : `260 + 100 × (${n} - 1) + 50 × ((${Q} - 1000) / 1000) = ${zhuanSeCost}`
            break
          case '对开':
            zhuanSeCost = Q <= 1000 ? 400 + 100 * (n - 1) : 400 + 100 * (n - 1) + 50 * ((Q - 1000) / 1000)
            zhuanSeCostStr = Q <= 1000 ? `400 + 100 × (${n} - 1) = ${zhuanSeCost}`
              : `400 + 100 × (${n} - 1) + 50 × ((${Q} - 1000) / 1000) = ${zhuanSeCost}`
            break
          default:
            zhuanSeCostStr = '0'
            zhuanSeCost = 0
            break
        }
      }
      return [siSeCostStr, zhuanSeCostStr]
    },
    computeFumoCost (k) {
      let x = parseInt(this.x)
      let y = parseInt(this.y)
      let q = parseInt(this.Q)
      let zhengPrice
      let zhengPriceStr
      let fanPrice
      let fanPriceStr
      let YList = [0.09, 0.1, 0.135, 0.7, 1.6, 0.7, 1.7]
      let moPrice = [0.4, 0.5, 0.6, 0.7, 1.6, 0.7, 1.7]
      let kaiPrice = [100, 100, 100, 120, 200, 150, 200]
      let YZheng = YList[this.option.fu_mo_option.indexOf(this.biaozhi.biao_ka['child' + k].fu_mo_zheng_mian)]
      let YFan = YList[this.option.fu_mo_option.indexOf(this.biaozhi.biao_ka['child' + k].fu_mo_fan_mian)]
      let moPZheng = moPrice[this.option.fu_mo_option.indexOf(this.biaozhi.biao_ka['child' + k].fu_mo_zheng_mian)]
      let moPFan = moPrice[this.option.fu_mo_option.indexOf(this.biaozhi.biao_ka['child' + k].fu_mo_fan_mian)]
      let m1 = (x + 15) * (y + 10) / Math.pow(10, 6)
      let m2 = (x + 10) * (y + 15) / Math.pow(10, 6)
      let m1Str = `(${x}+15)×(${y}+10)×(10^-6)`
      let m2Str = `(${x}+10)×(${y}+15)×(10^-6)`
      if (x <= y) {
        zhengPrice = m1 * moPZheng <= YZheng ? YZheng * q : m1 * moPZheng * q
        zhengPriceStr = m1 * moPZheng <= YZheng ? `${YZheng}×${q} = ${zhengPrice}` : m1Str + `×${moPZheng}×${q} = ${zhengPrice}`
        fanPrice = m1 * moPFan <= YFan ? YFan * q : m1 * moPFan * q
        fanPriceStr = m1 * moPFan <= YFan ? `${YFan}×${q} = ${fanPrice}` : m1Str + `×${moPFan}×${q} = ${fanPrice}`
      } else {
        zhengPrice = m2 * moPZheng <= YZheng ? YZheng * q : m2 * moPZheng * q
        zhengPriceStr = m2 * moPZheng <= YZheng ? `${YZheng}×${q} = ${zhengPrice}` : m2Str + `×${moPZheng}×${q} = ${zhengPrice}`
        fanPrice = m2 * moPFan <= YFan ? YFan * q : m2 * moPFan * q
        fanPriceStr = m2 * moPFan <= YFan ? `${YFan}×${q} = ${fanPrice}` : m2Str + `×${moPFan}×${q} = ${fanPrice}`
      }
      if (zhengPrice <= kaiPrice[this.option.fu_mo_option.indexOf(this.biaozhi.biao_ka['child' + k].fu_mo_zheng_mian)]) {
        zhengPriceStr = kaiPrice[this.option.fu_mo_option.indexOf(this.biaozhi.biao_ka['child' + k].fu_mo_zheng_mian)]
      }
      if (fanPrice <= kaiPrice[this.option.fu_mo_option.indexOf(this.biaozhi.biao_ka['child' + k].fu_mo_zheng_mian)]) {
        fanPriceStr = kaiPrice[this.option.fu_mo_option.indexOf(this.biaozhi.biao_ka['child' + k].fu_mo_zheng_mian)]
      }
      return [zhengPriceStr, fanPriceStr]
    },
    computeGuoyouCost (k) {
      let x = parseInt(this.x)
      let y = parseInt(this.y)
      let q = parseInt(this.Q)
      let ke = parseInt(this.biaozhi.biao_ka['child' + k].ke_zhong)
      let zhengPrice
      let zhengPriceStr
      let fanPrice
      let fanPriceStr
      let YList = ke <= 200 ? [0.07, 0.1, 0.08, 0.08, 0.16, 0.7, 1.1, 0.28] : [0.05, 0.1, 0.08, 0.08, 0.16, 0.7, 1.1, 0.28]
      let moPrice = ke <= 200 ? [0.25, 0.5, 0.28, 0.4, 0.7, 0.7, 1.1, 0.28] : [0.18, 0.5, 0.28, 0.4, 0.7, 0.7, 1.1, 0.28]
      let kaiPrice = ke <= 200 ? [100, 150, 100, 100, 100, 150, 150, 100] : [80, 150, 100, 100, 100, 150, 150, 100]
      let YZheng = YList[this.option.guo_you_option.indexOf(this.biaozhi.biao_ka['child' + k].guoyou_zheng_mian)]
      let YFan = YList[this.option.guo_you_option.indexOf(this.biaozhi.biao_ka['child' + k].guoyou_fan_mian)]
      let moPZheng = moPrice[this.option.guo_you_option.indexOf(this.biaozhi.biao_ka['child' + k].guoyou_zheng_mian)]
      let moPFan = moPrice[this.option.guo_you_option.indexOf(this.biaozhi.biao_ka['child' + k].guoyou_fan_mian)]
      let m1 = (x + 15) * (y + 10) / Math.pow(10, 6)
      let m2 = (x + 10) * (y + 15) / Math.pow(10, 6)
      let m1Str = `(${x}+15)×(${y}+10)×(10^-6)`
      let m2Str = `(${x}+10)×(${y}+15)×(10^-6)`
      if (x <= y) {
        zhengPrice = m1 * moPZheng <= YZheng ? YZheng * q : m1 * moPZheng * q
        zhengPriceStr = m1 * moPZheng <= YZheng ? `${YZheng}×${q} = ${zhengPrice}` : m1Str + `×${moPZheng}×${q} = ${zhengPrice}`
        fanPrice = m1 * moPFan <= YFan ? YFan * q : m1 * moPFan * q
        fanPriceStr = m1 * moPFan <= YFan ? `${YFan}×${q} = ${fanPrice}` : m1Str + `×${moPFan}×${q} = ${fanPrice}`
      } else {
        zhengPrice = m2 * moPZheng <= YZheng ? YZheng * q : m2 * moPZheng * q
        zhengPriceStr = m2 * moPZheng <= YZheng ? `${YZheng}×${q} = ${zhengPrice}` : m2Str + `×${moPZheng}×${q} = ${zhengPrice}`
        fanPrice = m2 * moPFan <= YFan ? YFan * q : m2 * moPFan * q
        fanPriceStr = m2 * moPFan <= YFan ? `${YFan}×${q} = ${fanPrice}` : m2Str + `×${moPFan}×${q} = ${fanPrice}`
      }
      if (zhengPrice <= kaiPrice[this.option.guo_you_option.indexOf(this.biaozhi.biao_ka['child' + k].guoyou_zheng_mian)]) {
        zhengPriceStr = kaiPrice[this.option.guo_you_option.indexOf(this.biaozhi.biao_ka['child' + k].guoyou_zheng_mian)]
      }
      if (fanPrice <= kaiPrice[this.option.guo_you_option.indexOf(this.biaozhi.biao_ka['child' + k].guoyou_fan_mian)]) {
        fanPriceStr = kaiPrice[this.option.guo_you_option.indexOf(this.biaozhi.biao_ka['child' + k].guoyou_fan_mian)]
      }
      return [zhengPriceStr, fanPriceStr]
    },
    computeTangjinCost (k) {
      let q = parseInt(this.Q)
      let n = parseInt(this.biaozhi.biao_ka['child' + k].ci_shu)
      let c = 0.1 * q
      let m = parseInt(this.m)
      let s = parseInt(this.biaozhi.biao_ka['child' + k].tang_jin_chang) * parseInt(this.biaozhi.biao_ka['child' + k].tang_jin_kuan)
      let b = parseInt(this.biaozhi.biao_ka['child' + k].tang_jin_jin_zhi)
      let cost = c <= 150 ? 150 * n + s * 0.2 * n * m + 50 * n + b : s * 0.2 * n * m + 50 * n + b
      return c <= 150 ? `150 × ${n} + ${s} × 0.2 × ${n} × ${m} + 50 × ${n} + ${b} = ${cost}` : `${s} × 0.2 × ${n} × ${m} + 50 × ${n} + ${b} = ${cost}`
    },
    clickToChange (name) {
      this.biaozhi[name].disable = !this.biaozhi[name].disable
    },
    lei_name (n, k) {
      let h = ['shuangtong', 'baika', 'baiban', 'shuangbai', 'yinka', 'jinka']
      let i = this.option.zhong_lei.indexOf(this.biaozhi[n]['child' + k].zhi_lei)
      return h[i]
    },
    getPrice (n, k) {
      let lei = this.lei_name(n, k)
      if (lei === 'shuangtong') {
        switch (this.biaozhi[n]['child' + k].ke_zhong) {
          case 105:
            this.biaozhi[n]['child' + k].dan_jia = 6000
            break
          case 128:
            this.biaozhi[n]['child' + k].dan_jia = 5900
            break
          default:
            this.biaozhi[n]['child' + k].dan_jia = 5800
            break
        }
      } else {
        let i = this.option.ke_zhong[lei].indexOf(this.biaozhi[n]['child' + k].ke_zhong)
        this.biaozhi[n]['child' + k].dan_jia = this.option.dan_jia[lei][i]
      }
      this.$forceUpdate()
    },
    clearInfo (n, k) {
      this.biaozhi[n]['child' + k].ke_zhong = ''
      this.biaozhi[n]['child' + k].dan_jia = ''
      this.$forceUpdate()
    }
  }
}
</script>

<style scoped>
.btn{
  margin: 10px 0;
}
.content{
  margin: 10px 0;
}

.check{
  margin-bottom: 10px;
}

.lengthq{
  margin-top: 10px;
}

.length{
  width: 100px;
  display: inline-block;
  margin-top: 10px;
  margin-right: 10px;
}

.color{
  color: orange;
}

.print_color{
  color: brown;
}

.hou_color{
  color: blueviolet;
}

.content_inline{
  display: inline-block;
}
.btn{
  margin: 10px 0;
}
</style>
